// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vant from 'vant';
import 'vant/lib/index.css';
import * as echarts from 'echarts';
var axios = require('axios')
import { Dialog } from 'vant';
axios.defaults.baseURL = 'http://localhost:8081/api'  //此处是https协议如果不是改成http
// 将API方法绑定到全局
Vue.prototype.$axios = axios



// 全局注册
Vue.use(Dialog);



Vue.use(Vant);
//需要挂载到Vue原型上
Vue.prototype.$echarts = echarts


// 添加请求拦截器，在请求头部加token
axios.interceptors.request.use(
  config =>{
    if(localStorage.getItem('Authorization')){
      config.headers.Authorization = localStorage.getItem('Authorization');
    }
    return config;
  },
  error =>{
    return Promise.reject(error);
  }
);


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
